#include "Head.h"

template<class T, class Container>
void Func()
{
	Container cont = { 1, 2, 3, 4, 5 };
	typename Container::iterator iter, tempIt;

	for (iter = cont.begin(); iter != cont.end();)
	{
		tempIt = iter;
		++iter;

		cont.erase(tempIt);
	}
}

void Test1(void)
{
	//Func<int, vector<int>>();// err
	Func<int, list<int>>();
	//Func<int, deque<int>>();// err
}

namespace yyp
{
	void StackTest(void)
	{
		//stack<int> s;
		//stack<int, list<int>> s;
		stack<int, vector<int>> s;

		s.push(5);
		s.push(4);
		s.push(3);
		s.push(2);
		s.push(1);
		cout << "top " << s.top() << endl;
		s.top() = 100;
		cout << "top " << s.top() << endl;
		cout << "***********************\n";

		cout << "top	" << "size	" << "empty	" << endl;
		while (!s.empty())
		{
			cout << s.top() << "	";
			cout << s.size() << "	" << s.empty() << endl;
			s.pop();
		}
		cout << "	" << s.size() << "	" << s.empty() << endl;
		cout << "-----------------------------------\n";
	}

	void QueueTest(void)
	{
		//queue<int> q;
		queue<int, list<int>> q;

		q.push(1);
		q.push(2);
		q.push(3);
		q.push(4);
		q.push(5);
		cout << "front	" << q.front() << "|back " << q.back() << endl;

		q.front() = 100;
		q.back() = 500;
		cout << "front " << q.front() << "|back " << q.back() << endl;
		cout << "**************************\n";

		cout << "front|back" << "	szie|empty" << endl;
		while (!q.empty())
		{
			cout << q.front() << "	" << q.back() << "	";
			cout << q.size() << "	" << q.empty() << endl;
			q.pop();
		}
		cout << "		" << q.size() << "	" << q.empty() << endl;
		cout << "-----------------------------------\n";
	}

	void Priority_QueueTest(void)
	{
		list<int> l1 = { 1, 2, 3, 4, 5, 6 };
		priority_queue<int, deque<int>, Greater<int>> pq(l1.begin(), l1.end());

		/*pq.push(1);
		pq.push(2);
		pq.push(3);
		pq.push(4);
		pq.push(5);
		pq.push(6);*/

		cout << "top	size	empty" << endl;
		while (!pq.empty())
		{
			cout << pq.top() << "	";
			cout << pq.size() << "	" << pq.empty() << endl;
			pq.pop();
		}
		cout << "	" << pq.size() << "	" << pq.empty() << endl;
	}
}


int main()
{
	//Test1();

	yyp::StackTest();
	yyp::QueueTest();
	yyp::Priority_QueueTest();
	
	return 0;
}